package cn.supermaster.management.web.controller.task;

import cn.supermaster.management.web.service.task.ISTaskService;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;

/**
 * All rights Reserved, Designed By www.super-bytecode.com
 *
 * @ProjectName: supermaster-management
 * @Package: cn.supermaster.management.web.controller
 * @ClassName: ScheduleTaskController
 * @Description: [定时任务Controller]
 * <p> 调度任务信息操作处理 </p>
 * @Author: [Lance Ting]
 * @Date: 2021/2/16 16:31
 * @Version: V1.0
 * @Copyright: 2021 www.super-bytecode.com Inc. All rights reserved.
 * TODO: 注意,本文件Lance Ting所作,如果转载或使用请标明具体出处!
 **/
@Controller
@RequestMapping("/monitor/job")
public class ScheduleTaskController {

    @Autowired
    private ISTaskService taskService;

    @RequiresPermissions("monitor:job:view")
    @GetMapping()
    public String skipJobIndex() {
        return taskService.skipScheduleTaskIndex();
    }

    @RequiresPermissions("monitor:job:detail")
    @GetMapping("/detail/{jobId}")
    public String detail(@PathVariable("jobId") Long taskId, ModelMap modelMap) {
        return taskService.skipScheduleTaskDetailsHtml(modelMap, taskId);
    }

    /**
     * 新增调度界面
     */
    @GetMapping("/add")
    public String skipAddScheduleTaskHtml() {
        return taskService.skipAddScheduleTaskHtml();
    }

    /**
     * 修改调度任务界面
     */
    @GetMapping("/edit/{jobId}")
    public String skipModifyScheduleTaskHtml(@PathVariable("jobId") Long taskId, ModelMap modelMap) {
        return taskService.skipModifyScheduleTaskHtml(modelMap, taskId);
    }
}